package com.ruoyi.bigScreen.controller;


import com.ruoyi.bigScreen.domain.vo.BigScreenWaterFeeCalculationVO;
import com.ruoyi.bigScreen.domain.vo.BigScreenWaterSumPlanVo;
import com.ruoyi.bigScreen.service.IBigScreenWaterFeeCalculationService;
import com.ruoyi.bigScreen.service.IBigScreenWaterSumPlanVoService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.Calendar;
import java.util.List;
/**
 * 获取机构应收实收水费
 *
 */
@RestController
@RequestMapping("/WaterFeeCalculation")
public class BigScreenWaterFeeCalculationVoController extends BaseController {

    @Autowired
    private IBigScreenWaterFeeCalculationService waterFeeCalculationService;

    /**
     * 获取机构应收实收水费
     * @return
     */
    @GetMapping("/listOrgReceivablePaidWaterFees")
    public AjaxResult listOrgReceivablePaidWaterFees(){
        List<BigScreenWaterFeeCalculationVO> waterFeeCalculationVO= waterFeeCalculationService.getOrgReceivablePaidWaterFees();
        return AjaxResult.success(waterFeeCalculationVO);
    }

    /**
     * 获取机构水费征收率
     * @return
     */
    @GetMapping("/listOrgWaterFeeCollectionRate")
    public AjaxResult listOrgWaterFeeCollectionRate(){
        List<BigScreenWaterFeeCalculationVO> waterFeeCalculationVO= waterFeeCalculationService.getOrgWaterFeeCollectionRate();
        for (BigScreenWaterFeeCalculationVO b:waterFeeCalculationVO
             ) {
            //应收费用0就是征收100%
            if (b.getTotalFee().compareTo(new BigDecimal("0"))==0){
                b.setRate(new BigDecimal("100"));
            }else if(b.getPayFee().compareTo(new BigDecimal("0"))==0){
                b.setRate(new BigDecimal("0"));
            }else {
                b.setRate(b.getTotalFee().divide(b.getPayFee(),2, BigDecimal.ROUND_HALF_UP));
            }
        }
        return AjaxResult.success(waterFeeCalculationVO);
    }
}
